
export class UIStack{
    private static defaultUI:UIScript
    private static replaceUI:UIScript

    static setDefault<T extends mw.UIScript>(uiClass: { new (): T} ): T{
        let defaultUI = UIService.show(uiClass)
        this.defaultUI = defaultUI
        return defaultUI
    }

    static replace<T extends mw.UIScript>(uiClass: { new (): T} ): T{
        // 关闭主界面
        UIService.hideUI(this.defaultUI)
        // 关闭上一个替换界面
        if(this.replaceUI){
            UIService.hideUI(this.replaceUI)
        }
        // 打开替换界面
        let ui = UIService.show(uiClass)
        this.replaceUI = ui
        return ui
    }

    static backToDefault(){
        if(this.replaceUI){
            UIService.hideUI(this.replaceUI)
            this.replaceUI = undefined
        }
        UIService.showUI(this.defaultUI)
    }
}
